﻿<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="ExamListControl.ascx.cs" Inherits="YiShi.Exam.ExamListControl" %>

<table width="<%=Width %>px" style="border-collapse: collapse; border: 1px solid #c5dbec;
    background-color: #f5f8f9">
    <tr>
        <td colspan="4" align="left">
            <font style="font-size: 11pt; font-weight: bold">查询条件</font>
        </td>
        <td align="right" rowspan="2">
            <button id="QueryButton">
                查询
            </button>
            &nbsp;
            <button id="EmptyButton">
                清空
            </button>
            &nbsp;
        </td>
    </tr>
    <tr>
        <td align="right">
            名称：
        </td>
        <td>
            <input name="Name" style="width: 50px;" />
        </td>
        <td align="right">
        </td>
        <td>
        </td>
    </tr>
</table>
<br />
<div style="width: <%=Width %>px; text-align: right;">
    <button id="DemoButton">
        演示
    </button>
    <button id="EditButton">
        编辑
    </button>
    &nbsp;&nbsp;
    <button id="InsertButton">
        新增
    </button>
    <button id="UpdateButton">
        修改
    </button>
    <button id="DeleteButton">
        删除
    </button>
</div>
<br />
<table width="<%=Width %>px" style="border-collapse: collapse" id="MainTable">
    <tr style="border: 1px solid #c5dbec; background-color: #f5f8f9">
        <td colspan="2" align="left">
            <font style="font-size: 11pt; font-weight: bold">试卷列表</font>
        </td>
    </tr>
    <tr style="background: #d0e5f5 url(/css/redmond/images/ui-bg_glass_75_d0e5f5_1x400.png) 50% 50% repeat-x;
        font-weight: bold; color: #1d5987;" align="center" id="__ListTitle">
        <td class="tdclass" width="10">
        </td>
        <td class="tdclass">
            <span id="Name" style="cursor: hand;">名称</span>
        </td>
    </tr>
    <%=html %>
    <tr style="border: 1px solid #c5dbec; background-color: #f5f8f9">
        <td colspan="2">
            <table width="100%" style="border-collapse: collapse" border="0">
                <tr>
                    <td align="left">
                        <button style='font-size: 0pt;' id="FirstButton">
                            <span class="ui-icon ui-icon-seek-first"></span>
                        </button>
                        <button style='font-size: 0pt;' id="PreviousButton">
                            <span class="ui-icon ui-icon-seek-prev"></span>
                        </button>
                        &nbsp;第<input style="width: 20px" value="<%=pi.CurrentPageNo %>" id="CPN">页/共<span
                            id="TPC"><%=pi.TotalPageCount %></span>页&nbsp;
                        <button style='font-size: 0pt;' id="NextButton">
                            <span class="ui-icon ui-icon-seek-next"></span>
                        </button>
                        <button style='font-size: 0pt;' id="LastButton">
                            <span class="ui-icon ui-icon-seek-end"></span>
                        </button>
                        &nbsp;每页<input style="width: 20px" value="<%=pi.PerPageRecordCount %>" id="PPRC">条
                    </td>
                    <td align="right" id="PageMsg">
                        当前页<span id="CPRC"><%=pi.CurrentPageRecordCount %></span>条/共<span id="TRC"><%=pi.TotalRecordCount %></span>条
                    </td>
                </tr>
            </table>
        </td>
    </tr>
</table>

<script language="javascript">
    $(function event() {
        //Init
        $("button").button();
        $("#QueryButton").bind("click", { "ActionType": "Jump" }, Jump);

        $("#InsertButton").click(function() {
            window.open("ExamEdit.aspx");
        });
        $("#UpdateButton").click(function() {
            var $ele = $("input:radio[name='Record']:checked");
            if ($ele.length == 0) {
                Alert("请选择要操作的记录！");
                return;
            }
            window.open("ExamEdit.aspx?ActionType=DataUpdate&Id=" + $ele.val());
        });
        $("#DeleteButton").click(function() {
            var $ele = $("input:radio[name='Record']:checked");
            if ($ele.length == 0) {
                Alert("请选择要操作的记录！");
                return;
            }
            window.open("ExamEdit.aspx?ActionType=DataDelete&Id=" + $ele.val());
        });
        $("#EditButton").click(function() {
            var $ele = $("input:radio[name='Record']:checked");
            if ($ele.length == 0) {
                Alert("请选择要操作的记录！");
                return;
            }
            window.open("ExamQuestionEdit.aspx?ActionType=DataEdit&Id=" + $ele.val());
        });
        $("#DemoButton").click(function() {
            var $ele = $("input:radio[name='Record']:checked");
            if ($ele.length == 0) {
                Alert("请选择要操作的记录！");
                return;
            }
            window.open("ExamDemo.aspx?Id=" + $ele.val());
        });                      
    });
    function Jump(event) {
        var jsondata = GetPageIndexSortInfo(event.data.ActionType, event.data.OrderBy);

        var where = "";
        var $ele = $("[name='Name']");
        if ($.trim($ele.val()) != "")
            where += String.format("Name like '%{0}%' and ", $.trim($ele.val()));
        if (where != "")
            where = "where " + where.substring(0, where.length - 4);
        jsondata["Where"] = where;

        ShowMask();
        $.post("ExamList.aspx", jsondata, function(data) {
            if (data.IsSuccess == "true") {
                var eles = $("#MainTable").children().children();
                for (var i = 0; i < eles.length; i++) {
                    if (i != 0 && i != 1 && i != eles.length - 1)
                        $(eles[i]).remove();
                }
                for (var i = 0; i < data.Trs.length; i++) {
                    var tr = unescape(data.Trs[i]);
                    $(tr).insertBefore($(eles[eles.length - 1]));
                }
                SetPageIndexSortInfo(jsondata["PageAction"], jsondata["OrderBy"], data.CPN, data.TPC, data.PPRC, data.CPRC, data.TRC);
            }
            else
                ShowError(data.Message, data.Source, data.StackTrace);
            HideMask();
        }, "json");
    }        
</script>
